package com.ccit.goods.config;

import org.springframework.boot.system.ApplicationHome;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author lishuai
 * @create 2022-04-13 21:16
 */
@Configuration("GoodsPicConfig")
public class MyPicConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/goods/img/**").
                addResourceLocations("file:" + new ApplicationHome(this.getClass()).getDir().getParentFile().getParentFile().getAbsolutePath() + "/src/main/resources/static/goods/img/");
    }
}
